package com.tzpay.tzpay.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.tzpay.tzpay.R;
import com.tzpay.tzpay.bean.UserInfo;
import com.tzpay.tzpay.ui.BaseFragment;
import com.tzpay.tzpay.ui.activity.SettingActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by chenfeiyue on 16/4/7.
 */
public class MeFragment extends BaseFragment {
    @Bind(R.id.sdv_me_shop_image)
    ImageView sdvMeShopImage;
    @Bind(R.id.tv_me_shop_name)
    TextView tvMeShopName;
    @Bind(R.id.tv_me_user_name)
    TextView tvMeUserName;
    @Bind(R.id.rl_change_password)
    View rlChangePassword;
    @Bind(R.id.rl_setting)
    View rlSetting;

    public static MeFragment instance() {
        MeFragment fragment = new MeFragment();
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_me, null);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        Glide.with(MeFragment.this)
                .load(UserInfo.getInstance().getShopLogo())
//                .load("http://ftp.ytbbs.com/attachments/forum/201404/14/165935vfzw45q2574ggvii.gif")
//                .asGif()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(sdvMeShopImage);
        tvMeShopName.setText(UserInfo.getInstance().getShopName());
        tvMeUserName.setText(UserInfo.getInstance().getShopTel());
    }

    @OnClick(R.id.rl_setting)
    public void onSettingClick() {
        startActivity(new Intent(getActivity(), SettingActivity.class));
    }

}
